
*******************************************************************************
****						Appendix Table G.19 - REGRESSION OF TOTAL TOLL ****
****			ON TIME DIFFERENTIALS: EXPECTED TRAVEL TIME				*******
*******************************************************************************


use ".\data\clean\I10W_laneuse_dataset_15nov14_wcensus", clear

merge m:1 date hour using ".\data\clean\HV_ML_reliab.dta", keep(1 3) nogen 
gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV

merge m:1 date hour using .\data\clean\HV_ML_meanspeeds_30days, keep(1 3) nogen
*WTP calculation
gen TT_dif_hr=dist/MLspeed-dist/ELspeed
gen WTP2=charged_toll/TT_dif_hr
drop if ELspeed==.
drop if TT_dif_hr==.
drop if holiday==1
la var TT_dif_hr "Travel Time"
la var reliability_diff "Reliability"
drop if dow==0|dow==6
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
keep if hour>4 & hour<9
replace reliability_diff=0 if reliability_diff<0.01
egen ETT_dif_hr2=mean(TT_dif_hr),by(dow hour min rt_id)
la var ETT_dif_hr2 "E[Travel Time] Sample Mean"

keep if TT_dif_hr>0 & ETT_dif_hr1>0 & ETT_dif_hr2>0

reg charged_toll TT_dif_hr  , cluster(rt_id)
est sto a1
qui sum TT_dif_hr if e(sample)==1
local ts1=round(`r(mean)'*60,.01)
estadd scalar ts=`ts1'
reg charged_toll ETT_dif_hr2  , cluster(rt_id)
est sto a3
qui sum ETT_dif_hr2 if e(sample)==1 
local ts3=round(`r(mean)'*60,.01)
estadd scalar ts=`ts3'


reg charged_toll TT_dif_hr reliability_diff , cluster(rt_id)
est sto a4
qui sum TT_dif_hr if e(sample)==1 
local ts4=round(`r(mean)'*60,.01)
estadd scalar ts=`ts4'
xi: reg charged_toll ETT_dif_hr2 reliability_diff , cluster(rt_id)
est sto a6
qui sum ETT_dif_hr2 if e(sample)==1
local ts6=round(`r(mean)'*60,.01)
estadd scalar ts=`ts6'


esttab  a1  a3 a4  a6 using ".\results\appendix\tabs\ATG19.csv", replace  ///
	cells(b(star fmt(%9.2f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) ///
	stats(N r2 ts,fmt(%9.0f %9.2f %9.2f) labels(Observations R-squared MeanTravelTime)) label ///
	order(_cons  TT_dif_hr  ETT_dif_hr2 reliability_diff) ///
	keep(reliability_diff  ETT_dif_hr2 TT_dif_hr _cons) ///
	mtitle(I II III IV)
insheet using ".\results\appendix\tabs\ATG19.csv", comma clear
export excel using ".\results\appendix\AppendixFigsTabs.xlsx", ///
	sheet("Appendix Table G.19", replace)
